<template>
 <view class="main">
	<view class="p1">拍手认证</view> 
	<view class="p2">
	  需填写以下前4项拍手信息，以进行拍手资质审核。所有填写的内容
	  仅用于拍手认证，平台绝不外泄。人脸识别和安全筛选平台暂时未开放，可以不用操作。
	</view>
	<view class="p3 mar">
	   <view class="p3-1">
		   <view class="ptxt3-1">
			 <image src="https://ppp.new.zeroitem.cn/ppp/cp1.png" class="pimg1"></image>
			 身份证信息  
		   </view>
		   <view class="ptxt3-2">需提供手持身份证正反面清晰照片</view>
	   </view>
	   <view class="p3-2" v-if="sfzinfo==''" @click="showszftc">去上传</view>
	   <view class="p3-2 curm" v-if="sfzinfo!=''" @click="showszftc">已上传</view>
	</view>
	<view class="line"></view>
	
	
	<view class="p3">
	   <view class="p3-1">
		   <view class="ptxt3-1">
			 <image src="https://ppp.new.zeroitem.cn/ppp/cp2.png" class="pimg1"></image>
			 区域与时间  
		   </view>
		   <view class="ptxt3-2">请填写服务区域与时间排挡，为您筛选订单</view>
	   </view>
	     <view class="p3-2" v-if="psinfo==''" @click="jumpps">去上传</view>
		 <view class="p3-2 curm" v-if="psinfo!=''" @click="jumpps">已上传</view>
	</view>
	<view class="line"></view>	
		
	<view class="p3">
	   <view class="p3-1">
		   <view class="ptxt3-1">
			 <image src="https://ppp.new.zeroitem.cn/ppp/my/4.png" class="pimg1"></image>
			 作品信息  
		   </view>
		   <view class="ptxt3-2">请提供往期影像作品，作为客户参考案例</view>
	   </view>
	   <view class="p3-2" @click="jumpzp()" v-if="zpinfo==''">去上传</view>
	   <view class="p3-2 curm" @click="jumpzp()" v-if="zpinfo!=''">已上传</view>
	</view>
	<view class="line"></view>	
	
   <view class="p3">
	   <view class="p3-1">
		   <view class="ptxt3-1">
			 <image src="https://ppp.new.zeroitem.cn/ppp/cp3.png" class="pimg1"></image>
			 个人信息  
		   </view>
		   <view class="ptxt3-2">请填写专业证书或相关影像行业培训资质文件</view>
	   </view>
	     <view class="p3-2" @click="jumppx()" v-if="pxinfo==''">去上传</view>
	     <view class="p3-2 curm" @click="jumppx()" v-if="pxinfo!=''">已上传</view>
	</view>
	<view class="line"></view>	
		
   <view class="p3">
	   <view class="p3-1">
		   <view class="ptxt3-1">
			 <image src="https://ppp.new.zeroitem.cn/ppp/cp4.png" class="pimg1"></image>
			 人脸识别  
		   </view>
		   <view class="ptxt3-2">请人脸识别，以确保本人登记</view>
	   </view>
	   <view class="p3-2">后续开放</view>
	</view>
	<view class="line"></view>			
		
   <view class="p3">
	   <view class="p3-1">
		   <view class="ptxt3-1">
			 <image src="https://ppp.new.zeroitem.cn/ppp/cp5.png" class="pimg1"></image>
			 安全筛查  
		   </view>
		   <view class="ptxt3-2">定期校验，严防风险</view>
	   </view>
	   <view class="p3-2">后续开放</view>
	</view>
	<view class="line"></view>	
	<view class="remark" v-if="flag==1">
	  当前拍手认证正在审核当中。预计在5个工作日内会有结果，有疑问咨询0592-5811220
	</view>
	<view class="remark blue" v-if="flag==2">
	  您的拍手身份已经审核通过
	</view>	
	<view class="remark red" v-if="flag==3">
	  审核不通过。{{remark}}
	</view>	
	
    <view class="sh1"  v-if="flag==0 || flag==3">
    <view class="shbtn" @click="pzcheck">提交审核</view>
	</view>

   <view class="mask" v-if="zt==1">
      <view class="qtc">
         <view class="sfzb1">实名认证</view> 
		  <view class="line"></view>
		  <view class="part3-1">
		       <input type="text" placeholder="请填写您的真实姓名" class="cinput" v-model="xm"/>
		  </view> 
		  <view class="part3-1">
		       <input type="text" placeholder="请填写身份证号码" class="cinput" v-model="idcard"/>
		  </view> 
		  
		  
		   <view class="sfzb2">
			  <view class="sb1" @click="uploadvideo(1)">
				<view class="sb1-1">
				  <image :src="vcard1" class="vimg"></image>	
				</view> 
			     <view class="sb1-2">手持身份证正面</view>
			  </view> 
			  <view class="sb2"></view>
			  <view class="sb3" @click="uploadvideo(2)">
				 <view class="sb1-1">
					<image :src="vcard2" class="vimg"></image>	 
				 </view>
				  <view class="sb1-2">手持身份证反面</view> 
			  </view>
		   </view>
		   <view class="line pa1"></view>
		   <view class="btnq" @click="addsfz()">提交认证</view>
	  </view>
   </view>

 </view>	
</template>
<script>
	import {
		mapGetters,
		mapActions
	} from 'vuex'
	import {
		toLogin
	} from '@/utils/login'
	
	import {
		loadingFun,
		menuJump
	} from '@/utils/tools'	
	import {
	  psrz,psrzinfo,pscheck
	} from '@/api/ppp'	
	import {
		loadingType
	} from '@/utils/type'
	
	import {
	  uploadFileToTencentClound
	} from '@/js_sdk/COS'
	
	const app = getApp()
	export default {
	    data() {
	        return {
             zt:0,
			 vcard1:"",
			 vcard2:"",
			 xm:"",
			 idcard:"",
			 zpinfo:"",
			 sfzinfo:"",
			 psinfo:"",
			 pxinfo:"",
			 flag:0,
			 remark:""
	        }
	    },
		onLoad(){
	     this.info();
		},
	    methods: {
		 showszftc(){
		  this.zt=1; 
		 },
		 jumpps(){
		  uni.redirectTo({
		  	url:"/pages/ppp/ps1/setdqzz"
		  })	 
		 },
		 async addsfz(){
		   var that=this;
		   var vcard1=this.vcard1;
		   var vcard2=this.vcard2;
		   var xm=this.xm;
		   var idcard=this.idcard;
		   if(xm=='' || xm==undefined){
		   	uni.showToast({title:"请填写您的真实姓名",icon:"none"}); 
		   	return false;
		    }	
		    if(idcard=='' || idcard==undefined){
				uni.showToast({title:"请填写您的身份证号",icon:"none"}); 
				return false;
			 }			   
		   if(vcard1=='' || vcard1==undefined){
				uni.showToast({title:"请上传身份证正面",icon:"none"}); 
				return false;
			 }	
			 if(vcard2=='' || vcard2==undefined){
				uni.showToast({title:"请上传身份证反面",icon:"none"}); 
				return false;
			 }	
		   var odata={xm:xm,idcard:idcard,vcard2:vcard2,vcard1:vcard1,part:"sfzinfo"};
		   const{
		   	 code,
		     msg,
		     data,
		   }= await psrz(odata);
		   if(code==1){that.sfzinfo=data;that.zt=0;}	
		 },	
		 async info(){
		  var that=this;
		  const{
		  	code,
		  	msg,
		  	data,
		   }= await psrzinfo();
		   if(code==1){
			if(data!=null){
	         that.zpinfo=data.zpinfo; 
			 that.psinfo=data.psinfo;
			 that.pxinfo=data.pxinfo;
			 var sfz=data.sfzinfo;
			 that.sfzinfo=sfz; 
			 that.vcard1=sfz.vcard1;
			 that.vcard2=sfz.vcard2;
			 that.xm=sfz.xm;
			 that.idcard=sfz.idcard;
			 that.flag=data.flag;
			 that.remark=data.remark;
			}
		   }		 
		 },
		 jumppx(){
			uni.redirectTo({
				url:"/pages/ppp/ps/psinfo"
			}) 	 
		 },
	     jumpzp(){
		  uni.redirectTo({
		  	url:"/pages/ppp/ps/tjzp1"
		  }) 
		 },
	  async pzcheck(){
		var  zpinfo=this.zpinfo;
		var  psinfo=this.psinfo;
		var  pxinfo=this.pxinfo;
		var sfzinfo=this.sfzinfo;
		var that=this;
		if(zpinfo=='' || zpinfo==undefined){
		 uni.showToast({title:"请上传作品信息",icon:"none"});
		 return false;
		}
		if(psinfo=='' || psinfo==undefined){
		 uni.showToast({title:"请设置区域和时间",icon:"none"});
		 return false;
		}		
		if(sfzinfo=='' || sfzinfo==undefined){
		 uni.showToast({title:"请上传身份证信息",icon:"none"});
		 return false;
		}	
			
		if(pxinfo=='' || pxinfo==undefined){
		 uni.showToast({title:"请填写个人信息",icon:"none"});
		 return false;
		}			
		const{
			 code,
		  msg,
		  data,
		}= await pscheck({});
		
		if(code==1){
		 that.flag=1;
		 uni.showToast({title:"提交审核中",icon:"none"});
		 return false;
		}	
		
	  },
      uploadvideo(flag){
			var that=this;
			uni.chooseImage({
				sourceType: ['camera', 'album'],
				success: function (res) {
	              const tempFilePaths = res.tempFilePaths;
				  var filePath=tempFilePaths[0];
				  let ext = filePath.substr(filePath.lastIndexOf('.') + 1);
				  var timestamp = (new Date()).valueOf();
				  var filename=timestamp+"."+ext;
				  uploadFileToTencentClound(filename,filePath).then((res1)=>{
                    uni.showToast({
                      title:res1,
					  icon:"none"
                    });
					console.log(res1);
			        if(flag==1){
					  that.vcard1='http://ppp-1300934138.cos.ap-shanghai.myqcloud.com/wxFile/'+filename;
					}
					if(flag==2){
					 that.vcard2='http://ppp-1300934138.cos.ap-shanghai.myqcloud.com/wxFile/'+filename;
					}
				  })
				 }
		    });  
		  },		  
	    },
		computed: {
			...mapGetters(['isLogin']),
		}
	}
</script>
<style>
 @import "./psrz.css";	
</style>
